<script src="/javascripts/util.js" type="text/javascript"></script>
<script src="/javascripts/calendar.js" type="text/javascript"></script>
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
    function checkNum(flag, msg_id, obj_name, msg_text)
{
    if (flag) {
        if ($(obj_name).value == "" || ! digCheck($(obj_name).value))
        {
            $(msg_id).innerText = msg_text;
            $(msg_id).style.display = "block";
            return false;
        }
        else return true;
    }
    else {
        $(msg_id).style.display = "none";
    }
}

function checkDate()
{
    //if (checkNum(true,'id_serial','serial','送货单号输入错误'))
    if (checkNum(true,'id_agent_id','agent_id','客户ID输入错误'))
        frmSalePaper.submit();
}
function showPaperWindow(id)
{
    window.open("/sale/show_print_sale_paper/"+id,"_blank","height=700,width=700,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
function showAgentWindow(id)
{
    window.open("/other_org/agent_info/"+id,"_blank","height=500,width=500,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}


</script>

<h1>报表中心 - <span id="secondHeading">查询送货单</span></h1>


<% if @flash[:notice] -%>
<div id="notice"><%= @flash[:notice] %></div>
<% end -%>

<form id="input-form" name="frmSalePaper" action="/query/goods_send" method="post">
    <table id="INPUT_TABLE">
        <tr>
            <td> 送货单号： </td>
            <td> <input type="text" name="serial" id="serial" maxlength="20" onfocus ="checkNum(false,'id_serial')" onblur="checkNum(true,'id_serial',this.id,'送货单号输入错误')"/> <div class="redNsg" id="id_serial" style="display:none;"></div>
            </tr>
            <tr>
                <tr>
                    <TD width="20%">客户：</TD>
                    <TD><select name="agent_id">
                            <%@agents_1.each do |agent|%>
                            <option value="<%=agent.id%>"><%=agent.name%></option>
                            <%end%>
                        </select>
                    </TD>
                </tr>
                <tr>
                    <td colspan="2" align="right">　
                        <input  type="button" value="查询" class="sub" onclick="checkDate()">
                    </td>
                </tr>
            </table>
        </form>
<STYLE type=text/css>
#compay_info{
    display: none;
}
</STYLE>

<%if @sale_papers%>
<div id="abc">

<table id="compay_info" cellpadding="0" cellspacing="0" border="0">
<tr style="font-size:20px;font-weight:bold;">
<td align="center"><%= @company_info ? @company_info[0].value : ''%></td>
</tr>

<tr style="font-size:20px;font-weight:bold;">
<td align="center">送货单</td>
</tr>

</table>
<br/>
<table id="compay_info" width="95%" cellpadding="0" cellspacing="0" border="0">
    <tr style="font-size:12px;">
        <td>客户姓名：<%= @agents ? @agents.name : '' %></td>
        <td>电话：<%= @agents ? @agents.phone : ''%></td>
        <td align="right" style="font-size:22px;"><font color="red"><%= params[:serial] %></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr style="font-size:12px;">
        <td>地址：<%= @agents ? @agents.address1 : '' %></td>
        <td>传真：<%= @agents ? @agents.fax : ''%></td>
        <td align="right">年&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
</table>

            
            <table border="0" id="LIST_TB">
                <TR id="LIST_TB_TITLE">
                    <td nowrap>订单号码</td>
                    <td nowrap>品名规格</td>
                    <td nowrap>F</td>
                    <td nowrap>B</td>
                    <td nowrap>P</td>
                    <td nowrap>单位</td>
                    <td nowrap>数量</td>
                    <td>单价</td>
                    <td>金额</td>
                    <td>导针规格</td>
                    <td>件数</td>
                    <td>备注</td>
                </tr>
                <%@sale_papers.each do |item|%>
                <TR id="LIST_TB_CONTENT1">
                    <td><%=item.customer_book_no%></td>
                    <td><%=item.serial%></td>
                    <td><%=item.F%></td>
                    <td><%=item.B%></td>
                    <td><%=item.P%></td>
                    <td>K</td>
                    <td><%= sprintf("%#.2f",item.current_count) %></td>
                    <td><%=item.price%></td>
                    <td align="center"><%= sprintf("%#.2f",item.current_count.to_f * item.price.to_f) %></td>
                    <td><%=item.name%></td>
                    <td><%=sprintf("%#.2f",item.goods_num) %></td>
                    <td><%=item.memo%></td>
                </tr>

                <%end%>
                <tr id="LIST_TB_CONTENT1">
                    <td align="left" colspan="12">注：收货时，请认真检查，验收无误后签名盖章；如有异议，请务必保持我公司产品原状，于七天之内通知本公司，否则一切损失由贵公司承担。</td>
                </tr>
            </table>
            <br/>
<table id="compay_info" width="92%">

<tr style="font-size:12px;">
<td align="left" colspan="2">地址：<%= @company_info ? @company_info[1].value : ''%></td>
<td align="center">电话：<%= @company_info ? @company_info[2].value : '' %></td>
<td align="center">传真：<%= @company_info ? @company_info[3].value : '' %></td>
</tr>

<tr style="font-size:12px;">
<td align="left">客户签收（盖章）：</td>
<td align="center">核准：</td>
<td align="center">送货人：</td>
<td align="center">制表：<%= @session[:account].employee.name %></td>
</tr>

</table>            
</div>
                <table>
                    <tr>
                        <td>
                            <input type="button" value="打印当前页" class="sub" onclick="openPrintWindow_special('abc')"/>
                            <input type="button" value="导出当前数据" class="sub" onclick="CellAreaExcel('LIST_TB')"/>
                        </td>
                    </tr>
                </table>
                <%end%>
